﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using COFE.IO;
using System.Text.RegularExpressions;
using COFE.Core.Utils;
using COFE.Core.Logger;

namespace COFE.Core.Tasks
{
    public class TaskProgressDispatcher : 
        IEventDispatcher<TaskProgressEventArgs>
    {

        #region Constructor


        #endregion

        #region Static Methods

        public void RegisterListener(IListener<TaskProgressEventArgs> listener)
        {
            lock (_registeredListeners)
                if (!_registeredListeners.Contains(listener))
                    _registeredListeners.Add(listener as ITaskProgressListener);
        }

        public void UnregisterListener(IListener<TaskProgressEventArgs> listener)
        {
            lock (_registeredListeners)
                if (_registeredListeners.Contains(listener))
                    _registeredListeners.Remove(listener as ITaskProgressListener);
        }


        public void DispatchEvent(object sender, TaskProgressEventArgs args)
        {         
            foreach (var listener in _registeredListeners)
            {
                //if (listener.ListeningActions.Length == 0 || listener.ListeningActions.Contains(COFETaskShared.ParentTaskId))
                //    listener.NotifyProgress(sender, args);
            }
        }

        #endregion

        #region Methods

        #endregion

        #region Data

        private List<ITaskProgressListener> _registeredListeners = new List<ITaskProgressListener>();

        #endregion

        #region Public Properties

        #endregion
    }
}
